<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets" template="/protected/template/template.xhtml">
	<ui:define name="content">
		<p:panel header="User Management">
			<p:messages />
			<p:panelGrid id="userManagementPanelGrid">
				<p:row>
					<p:column>
						<p:outputLabel value="Name" for="name" />
					</p:column>
					<p:column>
						<p:inputText id="name" value="#{userManagementBean.user.name}" required="true" />
					</p:column>
				</p:row>
				<p:row>
					<p:column>
						<p:outputLabel value="E-mail" for="email" />
					</p:column>
					<p:column>
						<p:inputText id="email" value="#{userManagementBean.user.email}" />
					</p:column>
				</p:row>
				<p:row>
					<p:column>
						<p:outputLabel value="Username" for="username" />
					</p:column>
					<p:column>
						<p:inputText id="username" value="#{userManagementBean.user.username}" required="true" />
					</p:column>
				</p:row>
				<p:row>
					<p:column>
						<p:outputLabel value="Password" for="password" />
					</p:column>
					<p:column>
						<p:password id="password" value="#{userManagementBean.user.password}" match="password" feedback="true" required="true" redisplay="true" />
					</p:column>
				</p:row>
				<p:row>
					<p:column>
						<p:outputLabel value="Confirm Password" for="confirmPassword" />
					</p:column>
					<p:column>
						<p:password id="confirmPassword" value="#{userManagementBean.user.password}" required="true" redisplay="true" />
					</p:column>
				</p:row>
				<p:row rendered="#{userManagementBean.roleRendered}">
					<p:column>
						<p:outputLabel value="Role" for="role" />
					</p:column>
					<p:column>
						<p:selectOneMenu id="role" value="#{userManagementBean.user.role}" required="true">
							<f:selectItems value="#{userManagementBean.roles}" var="role" itemValue="#{role}" itemLabel="#{role.label}" />
							<p:ajax update="userManagementPanelGrid" listener="#{userManagementBean.handleRoleChange}" />
						</p:selectOneMenu>
					</p:column>
				</p:row>
				<p:row rendered="#{userManagementBean.clientRendered}">
					<p:column>
						<p:outputLabel value="Client" for="client" />
					</p:column>
					<p:column>
						<p:selectOneMenu id="client" value="#{userManagementBean.user.client}" converter="genericEntityConverter" required="true">
							<f:selectItem itemValue="" itemLabel="" />
							<f:selectItems value="#{userManagementBean.clients}" var="client" itemValue="#{client}" itemLabel="#{client.name}" />
						</p:selectOneMenu>
					</p:column>
				</p:row>
				<p:row>
					<p:column>
						<p:commandButton value="Save" action="#{userManagementBean.save}" ajax="false" />
					</p:column>
				</p:row>
			</p:panelGrid>
		</p:panel>
	</ui:define>
</ui:composition>
